package com.easy.core.dbHandle;

import java.io.Serializable;
import java.util.List;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Order;

/**
 * <p>Description: </p>
 * <p>CreateDate:@2013-8-23</p>
 * @author zhangj
 */
public interface CommonDao{
	
	public <K> K findById(Class<K> clazz, Serializable id);
	
	public <K> K findById(String entityName, Serializable id);
	
	public <K> List<K> findAll(Class<K> clazz);
	
	public <K> List<K> findAll(String entityName);
	
	public <K> List<K> findByCriteria(DetachedCriteria dc);
	
	public <K> List<K> findTopByCriteria(DetachedCriteria dc, int num);
	
	public Long findCountByCriteria(final DetachedCriteria dc);
	
	public <K> PaginationSupport<K> findPageByCriteria(DetachedCriteria dc, int pageSize, int startIndex, List<Order> orderList);
	
	public List<?> findByHQL(final String hql, final Object... params);
	
	public Serializable save(Object object);
	
	public Serializable save(String entityName, Object object);
	
	public void update(Object object);
	
	public void update(String entityName, Object object);
	
	public void delete(Object object);
	
	public Session getCurrentSession(boolean allowCreate);
	
	public SessionFactory getSessionFactory();
	
}
